package com;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

/**
 * @author liyanhao
 * @Date 2023-04-05 13:38
 */
public class test {
    public static void main(String[] args) {
        List<QuotedPrices> quotedPrices = new ArrayList<>();
        QuotedPrices quotedPrices1 = new QuotedPrices();
        quotedPrices1.setQuotedPrices(BigDecimal.TEN);
        QuotedPrices quotedPrices2 = new QuotedPrices();
        quotedPrices2.setQuotedPrices(BigDecimal.ONE);
        quotedPrices.add(quotedPrices1);
        quotedPrices.add(quotedPrices2);

        BigDecimal avg = quotedPrices.stream().map(v -> v.getQuotedPrices())
                .reduce(BigDecimal.ZERO, BigDecimal::add)
                .divide(BigDecimal.valueOf(quotedPrices.size()), 2, BigDecimal.ROUND_HALF_UP);
        System.out.println(avg);
    }

}

class QuotedPrices {
    private BigDecimal QuotedPrice;

    public BigDecimal getQuotedPrices() {
        return QuotedPrice;
    }

    public void setQuotedPrices(BigDecimal quotedPrices) {
        this.QuotedPrice = quotedPrices;
    }
}
